import {
	createRouter,
	createWebHistory
} from 'vue-router'
//导入组件
// import LoginVue from '@/views/Login.vue'
// import LayoutVue from '@/views/Layout.vue'
//import Login111Vue from '@/views/user/Login111.vue'
import UserVue from '@/views/user/User.vue'
import HomeVue from '@/views/user/Home.vue'
import UserInfoVue from '@/views/user/info/UserInfo.vue'
import InspectionVue from '@/views/user/info/Inspection.vue'
import RegistrationVue from '@/views/user/info/Registration.vue'
import PrescriptionVue from '@/views/user/info/Prescription.vue'
import SettingVue from '@/views/user/info/Setting.vue'

// 定义路由关系
// path  ：访问的路径    ；component:展示的组件
const routes = [
	{
		path: '/',
		component: UserVue,
		meta: {
			title: '登录',
			keepAlive:false,//是否缓存
			requireAuth:false//是否需要身份验证
		}
	},
	{
		path: '/user',
		component: UserVue,
		meta: {
			title: '登录'
		}
	},
	{
		path: '/home',
		component: HomeVue,
		redirect: '/user/userinfo', //重定向，默认首页的访问页面
		children: [{
				path: '/user/userinfo',
				component: UserInfoVue,
				meta: { keepAlive: false } // 确保禁用缓存
			},
			{
				path: '/user/inspection',
				component: InspectionVue
			},
			{
				path: '/user/registration',
				component: RegistrationVue
			},
			{
				path: '/user/prescription',
				component: PrescriptionVue
			},
			{
				path: '/user/setting',
				component: SettingVue
			}
		]
	}
]

//创建路由器
const router = createRouter({
	//使用History模式
	history: createWebHistory(),
	//传递刚刚定义好的路由关系 routes
	routes: routes
});

//导出路由
export default router